<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>keyboardshortcuthandler.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_keyboardshortcuthandler.js.html">keyboardshortcuthandler.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2006 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Generic keyboard shortcut handler.
<a name="line17"></a> *
<a name="line18"></a> * @see ../demos/keyboardshortcuts.html
<a name="line19"></a> */
<a name="line20"></a>
<a name="line21"></a>goog.provide(&#39;goog.ui.KeyboardShortcutEvent&#39;);
<a name="line22"></a>goog.provide(&#39;goog.ui.KeyboardShortcutHandler&#39;);
<a name="line23"></a>goog.provide(&#39;goog.ui.KeyboardShortcutHandler.EventType&#39;);
<a name="line24"></a>
<a name="line25"></a>goog.require(&#39;goog.Timer&#39;);
<a name="line26"></a>goog.require(&#39;goog.events&#39;);
<a name="line27"></a>goog.require(&#39;goog.events.Event&#39;);
<a name="line28"></a>goog.require(&#39;goog.events.EventTarget&#39;);
<a name="line29"></a>goog.require(&#39;goog.events.KeyCodes&#39;);
<a name="line30"></a>goog.require(&#39;goog.events.KeyNames&#39;);
<a name="line31"></a>goog.require(&#39;goog.object&#39;);
<a name="line32"></a>
<a name="line33"></a>
<a name="line34"></a>/**
<a name="line35"></a> * Component for handling keyboard shortcuts. A shortcut is registered and bound
<a name="line36"></a> * to a specific identifier. Once the shortcut is triggered an event is fired
<a name="line37"></a> * with the identifier for the shortcut. This allows keyboard shortcuts to be
<a name="line38"></a> * customized without modifying the code that listens for them.
<a name="line39"></a> *
<a name="line40"></a> * Supports keyboard shortcuts triggered by a single key, a stroke stroke (key
<a name="line41"></a> * plus at leat one modifier) and a sequence of keys or strokes.
<a name="line42"></a> *
<a name="line43"></a> * @param {goog.events.EventTarget|EventTarget} keyTarget Event target that the
<a name="line44"></a> *     key event listener is attached to, typically the applications root
<a name="line45"></a> *     container.
<a name="line46"></a> * @constructor
<a name="line47"></a> * @extends {goog.events.EventTarget}
<a name="line48"></a> */
<a name="line49"></a>goog.ui.KeyboardShortcutHandler = function(keyTarget) {
<a name="line50"></a>  goog.events.EventTarget.call(this);
<a name="line51"></a>
<a name="line52"></a>  /**
<a name="line53"></a>   * Registered keyboard shortcuts tree. Stored as a map with the keyCode and
<a name="line54"></a>   * modifier(s) as the key and either a list of further strokes or the shortcut
<a name="line55"></a>   * task identifier as the value.
<a name="line56"></a>   * @type {Object}
<a name="line57"></a>   * @see #makeKey_
<a name="line58"></a>   * @private
<a name="line59"></a>   */
<a name="line60"></a>  this.shortcuts_ = {};
<a name="line61"></a>
<a name="line62"></a>  /**
<a name="line63"></a>   * List of the last sequence of strokes. Object contains time last key was
<a name="line64"></a>   * pressed and an array of strokes, represented by numeric value.
<a name="line65"></a>   * @type {Object}
<a name="line66"></a>   * @private
<a name="line67"></a>   */
<a name="line68"></a>  this.lastKeys_ = {
<a name="line69"></a>    strokes: [],
<a name="line70"></a>    time: 0
<a name="line71"></a>  };
<a name="line72"></a>
<a name="line73"></a>  /**
<a name="line74"></a>   * List of numeric key codes for keys that are safe to always regarded as
<a name="line75"></a>   * shortcuts, even if entered in a textarea or input field.
<a name="line76"></a>   * @type {Object}
<a name="line77"></a>   * @private
<a name="line78"></a>   */
<a name="line79"></a>  this.globalKeys_ = goog.object.createSet(
<a name="line80"></a>      goog.ui.KeyboardShortcutHandler.DEFAULT_GLOBAL_KEYS_);
<a name="line81"></a>
<a name="line82"></a>  /**
<a name="line83"></a>   * Whether to always prevent the default action if a shortcut event is fired.
<a name="line84"></a>   * @type {boolean}
<a name="line85"></a>   * @private
<a name="line86"></a>   */
<a name="line87"></a>  this.alwaysPreventDefault_ = true;
<a name="line88"></a>
<a name="line89"></a>  /**
<a name="line90"></a>   * Whether to treat all shortcuts as if they had been passed
<a name="line91"></a>   * to setGlobalKeys().
<a name="line92"></a>   * @type {boolean}
<a name="line93"></a>   * @private
<a name="line94"></a>   */
<a name="line95"></a>  this.allShortcutsAreGlobal_ = false;
<a name="line96"></a>
<a name="line97"></a>  this.initializeKeyListener(keyTarget);
<a name="line98"></a>};
<a name="line99"></a>goog.inherits(goog.ui.KeyboardShortcutHandler, goog.events.EventTarget);
<a name="line100"></a>
<a name="line101"></a>
<a name="line102"></a>/**
<a name="line103"></a> * Maximum allowed delay, in milliseconds, allowed between the first and second
<a name="line104"></a> * key in a key sequence.
<a name="line105"></a> * @type {number}
<a name="line106"></a> */
<a name="line107"></a>goog.ui.KeyboardShortcutHandler.MAX_KEY_SEQUENCE_DELAY = 1500; // 1.5 sec
<a name="line108"></a>
<a name="line109"></a>
<a name="line110"></a>/**
<a name="line111"></a> * Bit values for modifier keys.
<a name="line112"></a> * @enum {number}
<a name="line113"></a> */
<a name="line114"></a>goog.ui.KeyboardShortcutHandler.Modifiers = {
<a name="line115"></a>  NONE: 0,
<a name="line116"></a>  SHIFT: 1,
<a name="line117"></a>  CTRL: 2,
<a name="line118"></a>  ALT: 4,
<a name="line119"></a>  META: 8
<a name="line120"></a>};
<a name="line121"></a>
<a name="line122"></a>
<a name="line123"></a>/**
<a name="line124"></a> * Keys marked as global by default.
<a name="line125"></a> * @type {Array.&lt;goog.events.KeyCodes&gt;}
<a name="line126"></a> * @private
<a name="line127"></a> */
<a name="line128"></a>goog.ui.KeyboardShortcutHandler.DEFAULT_GLOBAL_KEYS_ = [
<a name="line129"></a>  goog.events.KeyCodes.ESC,
<a name="line130"></a>  goog.events.KeyCodes.F1,
<a name="line131"></a>  goog.events.KeyCodes.F2,
<a name="line132"></a>  goog.events.KeyCodes.F3,
<a name="line133"></a>  goog.events.KeyCodes.F4,
<a name="line134"></a>  goog.events.KeyCodes.F5,
<a name="line135"></a>  goog.events.KeyCodes.F6,
<a name="line136"></a>  goog.events.KeyCodes.F7,
<a name="line137"></a>  goog.events.KeyCodes.F8,
<a name="line138"></a>  goog.events.KeyCodes.F9,
<a name="line139"></a>  goog.events.KeyCodes.F10,
<a name="line140"></a>  goog.events.KeyCodes.F11,
<a name="line141"></a>  goog.events.KeyCodes.F12,
<a name="line142"></a>  goog.events.KeyCodes.PAUSE
<a name="line143"></a>];
<a name="line144"></a>
<a name="line145"></a>
<a name="line146"></a>/**
<a name="line147"></a> * Events.
<a name="line148"></a> * @enum {string}
<a name="line149"></a> */
<a name="line150"></a>goog.ui.KeyboardShortcutHandler.EventType = {
<a name="line151"></a>  SHORTCUT_TRIGGERED: &#39;shortcut&#39;,
<a name="line152"></a>  SHORTCUT_PREFIX: &#39;shortcut_&#39;
<a name="line153"></a>};
<a name="line154"></a>
<a name="line155"></a>
<a name="line156"></a>/**
<a name="line157"></a> * Cache for name to key code lookup.
<a name="line158"></a> * @type {Object}
<a name="line159"></a> * @private
<a name="line160"></a> */
<a name="line161"></a>goog.ui.KeyboardShortcutHandler.nameToKeyCodeCache_;
<a name="line162"></a>
<a name="line163"></a>
<a name="line164"></a>/**
<a name="line165"></a> * Target on which to listen for key events.
<a name="line166"></a> * @type {goog.events.EventTarget|EventTarget}
<a name="line167"></a> * @private
<a name="line168"></a> */
<a name="line169"></a>goog.ui.KeyboardShortcutHandler.prototype.keyTarget_;
<a name="line170"></a>
<a name="line171"></a>
<a name="line172"></a>/**
<a name="line173"></a> * Due to a bug in the way that Gecko v1.8 on Mac handles
<a name="line174"></a> * cut/copy/paste key events using the meta key, it is necessary to
<a name="line175"></a> * fake the keydown for the action key (C,V,X) by capturing it on keyup.
<a name="line176"></a> * Because users will often release the meta key a slight moment
<a name="line177"></a> * before they release the action key, we need this variable that will
<a name="line178"></a> * store whether the meta key has been released recently.
<a name="line179"></a> * It will be cleared after a short delay in the key handling logic.
<a name="line180"></a> * @type {boolean}
<a name="line181"></a> * @private
<a name="line182"></a> */
<a name="line183"></a>goog.ui.KeyboardShortcutHandler.prototype.metaKeyRecentlyReleased_;
<a name="line184"></a>
<a name="line185"></a>
<a name="line186"></a>/**
<a name="line187"></a> * Static method for getting the key code for a given key.
<a name="line188"></a> * @param {string} name Name of key.
<a name="line189"></a> * @return {number} The key code.
<a name="line190"></a> */
<a name="line191"></a>goog.ui.KeyboardShortcutHandler.getKeyCode = function(name) {
<a name="line192"></a>  // Build reverse lookup object the first time this method is called.
<a name="line193"></a>  if (!goog.ui.KeyboardShortcutHandler.nameToKeyCodeCache_) {
<a name="line194"></a>    var map = {};
<a name="line195"></a>    for (var key in goog.events.KeyNames) {
<a name="line196"></a>      map[goog.events.KeyNames[key]] = key;
<a name="line197"></a>    }
<a name="line198"></a>    goog.ui.KeyboardShortcutHandler.nameToKeyCodeCache_ = map;
<a name="line199"></a>  }
<a name="line200"></a>
<a name="line201"></a>  // Check if key is in cache.
<a name="line202"></a>  return goog.ui.KeyboardShortcutHandler.nameToKeyCodeCache_[name];
<a name="line203"></a>};
<a name="line204"></a>
<a name="line205"></a>
<a name="line206"></a>/**
<a name="line207"></a> * Sets whether to always prevent the default action when a shortcut event is
<a name="line208"></a> * fired. If false, the default action is prevented only if preventDefault is
<a name="line209"></a> * called on  either of the corresponding SHORTCUT_TRIGGERED or SHORTCUT_PREFIX
<a name="line210"></a> * events. If true, the default action is prevented whenever a shortcut event
<a name="line211"></a> * is fired. The default value is true.
<a name="line212"></a> * @param {boolean} alwaysPreventDefault Whether to always call preventDefault.
<a name="line213"></a> */
<a name="line214"></a>goog.ui.KeyboardShortcutHandler.prototype.setAlwaysPreventDefault = function(
<a name="line215"></a>    alwaysPreventDefault) {
<a name="line216"></a>  this.alwaysPreventDefault_ = alwaysPreventDefault;
<a name="line217"></a>};
<a name="line218"></a>
<a name="line219"></a>
<a name="line220"></a>/**
<a name="line221"></a> * Returns whether the default action will always be prevented when a shortcut
<a name="line222"></a> * event is fired. The default value is true.
<a name="line223"></a> * @see #setAlwaysPreventDefault
<a name="line224"></a> * @return {boolean} Whether preventDefault will always be called.
<a name="line225"></a> */
<a name="line226"></a>goog.ui.KeyboardShortcutHandler.prototype.getAlwaysPreventDefault = function() {
<a name="line227"></a>  return this.alwaysPreventDefault_;
<a name="line228"></a>};
<a name="line229"></a>
<a name="line230"></a>
<a name="line231"></a>/**
<a name="line232"></a> * Sets whether to treat all shortcuts as if the keys had been passed to the
<a name="line233"></a> * setGlobalKeys function.
<a name="line234"></a> * @param {boolean} allShortcutsGlobal Whether to treat all shortcuts as global.
<a name="line235"></a> */
<a name="line236"></a>goog.ui.KeyboardShortcutHandler.prototype.setAllShortcutsAreGlobal = function(
<a name="line237"></a>    allShortcutsGlobal) {
<a name="line238"></a>  this.allShortcutsAreGlobal_ = allShortcutsGlobal;
<a name="line239"></a>};
<a name="line240"></a>
<a name="line241"></a>
<a name="line242"></a>/**
<a name="line243"></a> * Returns whether all shortcuts are treated as if they keys were passed
<a name="line244"></a> * to setGlobalKeys function.
<a name="line245"></a> * @see #setAllShortcutsAreGlobal
<a name="line246"></a> * @return {boolean} Whether all shortcuts are treated as globals.
<a name="line247"></a> */
<a name="line248"></a>goog.ui.KeyboardShortcutHandler.prototype.getAllShortcutsAreGlobal =
<a name="line249"></a>    function() {
<a name="line250"></a>  return this.allShortcutsAreGlobal_;
<a name="line251"></a>};
<a name="line252"></a>
<a name="line253"></a>
<a name="line254"></a>/**
<a name="line255"></a> * Registers a keyboard shortcut.
<a name="line256"></a> * @param {string} identifier Identifier for the task performed by the keyboard
<a name="line257"></a> *                 combination. Multiple shortcuts can be provided for the same
<a name="line258"></a> *                 task by specifying the same identifier.
<a name="line259"></a> * @param {number|string|Array.&lt;number&gt;} var_args See below.
<a name="line260"></a> *
<a name="line261"></a> * param {number} keyCode Numeric code for key
<a name="line262"></a> * param {number} opt_modifiers Bitmap indicating required modifier keys.
<a name="line263"></a> *                goog.ui.KeyboardShortcutHandler.Modifiers.SHIFT, CONTROL,
<a name="line264"></a> *                ALT, or META.
<a name="line265"></a> *
<a name="line266"></a> * The last two parameters can be repeated any number of times to create a
<a name="line267"></a> * shortcut using a sequence of strokes. Instead of varagrs the second parameter
<a name="line268"></a> * could also be an array where each element would be ragarded as a parameter.
<a name="line269"></a> *
<a name="line270"></a> * A string representation of the shortcut can be supplied instead of the last
<a name="line271"></a> * two parameters. In that case the method only takes two arguments, the
<a name="line272"></a> * identifier and the string.
<a name="line273"></a> *
<a name="line274"></a> * Examples:
<a name="line275"></a> *   g               registerShortcut(str, G_KEYCODE)
<a name="line276"></a> *   Ctrl+g          registerShortcut(str, G_KEYCODE, CTRL)
<a name="line277"></a> *   Ctrl+Shift+g    registerShortcut(str, G_KEYCODE, CTRL | SHIFT)
<a name="line278"></a> *   Ctrl+g a        registerShortcut(str, G_KEYCODE, CTRL, A_KEYCODE)
<a name="line279"></a> *   Ctrl+g Shift+a  registerShortcut(str, G_KEYCODE, CTRL, A_KEYCODE, SHIFT)
<a name="line280"></a> *   g a             registerShortcut(str, G_KEYCODE, NONE, A_KEYCODE)
<a name="line281"></a> *
<a name="line282"></a> * Examples using string representation for shortcuts:
<a name="line283"></a> *   g               registerShortcut(str, &#39;g&#39;)
<a name="line284"></a> *   Ctrl+g          registerShortcut(str, &#39;ctrl+g&#39;)
<a name="line285"></a> *   Ctrl+Shift+g    registerShortcut(str, &#39;ctrl+shift+g&#39;)
<a name="line286"></a> *   Ctrl+g a        registerShortcut(str, &#39;ctrl+g a&#39;)
<a name="line287"></a> *   Ctrl+g Shift+a  registerShortcut(str, &#39;ctrl+g shift+a&#39;)
<a name="line288"></a> *   g a             registerShortcut(str, &#39;g a&#39;).
<a name="line289"></a> */
<a name="line290"></a>goog.ui.KeyboardShortcutHandler.prototype.registerShortcut = function(
<a name="line291"></a>    identifier, var_args) {
<a name="line292"></a>
<a name="line293"></a>  // Add shortcut to shortcuts_ tree
<a name="line294"></a>  goog.ui.KeyboardShortcutHandler.setShortcut_(
<a name="line295"></a>      this.shortcuts_, this.interpretStrokes_(1, arguments), identifier);
<a name="line296"></a>};
<a name="line297"></a>
<a name="line298"></a>
<a name="line299"></a>/**
<a name="line300"></a> * Unregisters a keyboard shortcut by keyCode and modifiers or string
<a name="line301"></a> * representation of sequence.
<a name="line302"></a> *
<a name="line303"></a> * param {Number} keyCode Numeric code for key
<a name="line304"></a> * param {Number} opt_modifiers Bitmap indicating required modifier keys.
<a name="line305"></a> *                 goog.ui.KeyboardShortcutHandler.Modifiers.SHIFT, CONTROL,
<a name="line306"></a> *                 ALT, or META.
<a name="line307"></a> *
<a name="line308"></a> * The two parameters can be repeated any number of times to create a shortcut
<a name="line309"></a> * using a sequence of strokes.
<a name="line310"></a> *
<a name="line311"></a> * A string representation of the shortcut can be supplied instead see
<a name="line312"></a> * {@link #registerShortcut} for syntax. In that case the method only takes one
<a name="line313"></a> * argument.
<a name="line314"></a> *
<a name="line315"></a> * @param {number|string|Array.&lt;number&gt;} var_args String representation, or
<a name="line316"></a> *     array or list of alternating key codes and modifiers.
<a name="line317"></a> */
<a name="line318"></a>goog.ui.KeyboardShortcutHandler.prototype.unregisterShortcut = function(
<a name="line319"></a>    var_args) {
<a name="line320"></a>  // Remove shortcut from tree
<a name="line321"></a>  goog.ui.KeyboardShortcutHandler.setShortcut_(
<a name="line322"></a>      this.shortcuts_, this.interpretStrokes_(0, arguments), null);
<a name="line323"></a>};
<a name="line324"></a>
<a name="line325"></a>
<a name="line326"></a>/**
<a name="line327"></a> * Verifies if a particular keyboard shortcut is registered already. It has
<a name="line328"></a> * the same interface as the unregistering of shortcuts.
<a name="line329"></a> *
<a name="line330"></a> * param {Number} keyCode Numeric code for key
<a name="line331"></a> * param {Number} opt_modifiers Bitmap indicating required modifier keys.
<a name="line332"></a> *                 goog.ui.KeyboardShortcutHandler.Modifiers.SHIFT, CONTROL,
<a name="line333"></a> *                 ALT, or META.
<a name="line334"></a> *
<a name="line335"></a> * The two parameters can be repeated any number of times to create a shortcut
<a name="line336"></a> * using a sequence of strokes.
<a name="line337"></a> *
<a name="line338"></a> * A string representation of the shortcut can be supplied instead see
<a name="line339"></a> * {@link #registerShortcut} for syntax. In that case the method only takes one
<a name="line340"></a> * argument.
<a name="line341"></a> *
<a name="line342"></a> * @param {number|string|Array.&lt;number&gt;} var_args String representation, or
<a name="line343"></a> *     array or list of alternating key codes and modifiers.
<a name="line344"></a> * @return {boolean} Whether the specified keyboard shortcut is registered.
<a name="line345"></a> */
<a name="line346"></a>goog.ui.KeyboardShortcutHandler.prototype.isShortcutRegistered = function(
<a name="line347"></a>    var_args) {
<a name="line348"></a>  return this.checkShortcut_(this.interpretStrokes_(0, arguments));
<a name="line349"></a>};
<a name="line350"></a>
<a name="line351"></a>
<a name="line352"></a>/**
<a name="line353"></a> * Parses the variable arguments for registerShortcut and unregisterShortcut.
<a name="line354"></a> * @param {number} initialIndex The first index of &quot;args&quot; to treat as
<a name="line355"></a> *     variable arguments.
<a name="line356"></a> * @param {Object} args The &quot;arguments&quot; array passed
<a name="line357"></a> *     to registerShortcut or unregisterShortcut.  Please see the comments in
<a name="line358"></a> *     registerShortcut for list of allowed forms.
<a name="line359"></a> * @return {Array.&lt;Object&gt;} The sequence of objects containing the
<a name="line360"></a> *     keyCode and modifiers of each key in sequence.
<a name="line361"></a> * @private
<a name="line362"></a> */
<a name="line363"></a>goog.ui.KeyboardShortcutHandler.prototype.interpretStrokes_ = function(
<a name="line364"></a>    initialIndex, args) {
<a name="line365"></a>  var strokes;
<a name="line366"></a>
<a name="line367"></a>  // Build strokes array from string.
<a name="line368"></a>  if (goog.isString(args[initialIndex])) {
<a name="line369"></a>    strokes = goog.ui.KeyboardShortcutHandler.parseStringShortcut(
<a name="line370"></a>        args[initialIndex]);
<a name="line371"></a>
<a name="line372"></a>  // Build strokes array from arguments list or from array.
<a name="line373"></a>  } else {
<a name="line374"></a>    var strokesArgs = args, i = initialIndex;
<a name="line375"></a>    if (goog.isArray(args[initialIndex])) {
<a name="line376"></a>      strokesArgs = args[initialIndex];
<a name="line377"></a>      i = 0;
<a name="line378"></a>    }
<a name="line379"></a>
<a name="line380"></a>    strokes = [];
<a name="line381"></a>    for (; i &lt; strokesArgs.length; i += 2) {
<a name="line382"></a>      strokes.push({
<a name="line383"></a>        keyCode: strokesArgs[i],
<a name="line384"></a>        modifiers: strokesArgs[i + 1]
<a name="line385"></a>      });
<a name="line386"></a>    }
<a name="line387"></a>  }
<a name="line388"></a>
<a name="line389"></a>  return strokes;
<a name="line390"></a>};
<a name="line391"></a>
<a name="line392"></a>
<a name="line393"></a>/**
<a name="line394"></a> * Unregisters all keyboard shortcuts.
<a name="line395"></a> */
<a name="line396"></a>goog.ui.KeyboardShortcutHandler.prototype.unregisterAll = function() {
<a name="line397"></a>  this.shortcuts_ = {};
<a name="line398"></a>};
<a name="line399"></a>
<a name="line400"></a>
<a name="line401"></a>/**
<a name="line402"></a> * Sets the global keys; keys that are safe to always regarded as shortcuts,
<a name="line403"></a> * even if entered in a textarea or input field.
<a name="line404"></a> * @param {Array.&lt;number&gt;} keys List of keys.
<a name="line405"></a> */
<a name="line406"></a>goog.ui.KeyboardShortcutHandler.prototype.setGlobalKeys = function(keys) {
<a name="line407"></a>  this.globalKeys_ = goog.object.createSet(keys);
<a name="line408"></a>};
<a name="line409"></a>
<a name="line410"></a>
<a name="line411"></a>/**
<a name="line412"></a> * @return {Array.&lt;number&gt;} The global keys, i.e. keys that are safe to always
<a name="line413"></a> *     regard as shortcuts, even if entered in a textarea or input field.
<a name="line414"></a> */
<a name="line415"></a>goog.ui.KeyboardShortcutHandler.prototype.getGlobalKeys = function() {
<a name="line416"></a>  return goog.object.getKeys(this.globalKeys_)
<a name="line417"></a>};
<a name="line418"></a>
<a name="line419"></a>
<a name="line420"></a>/**
<a name="line421"></a> * Removes all event listeners and clears shortcuts.
<a name="line422"></a> */
<a name="line423"></a>goog.ui.KeyboardShortcutHandler.prototype.disposeInternal = function() {
<a name="line424"></a>  goog.ui.KeyboardShortcutHandler.superClass_.disposeInternal.call(this);
<a name="line425"></a>  this.unregisterAll();
<a name="line426"></a>  this.clearKeyListener();
<a name="line427"></a>};
<a name="line428"></a>
<a name="line429"></a>
<a name="line430"></a>/**
<a name="line431"></a> * Returns event type for a specific shortcut.
<a name="line432"></a> * @param {string} identifier Identifier for the shortcut task.
<a name="line433"></a> * @return {string} Theh event type.
<a name="line434"></a> */
<a name="line435"></a>goog.ui.KeyboardShortcutHandler.prototype.getEventType =
<a name="line436"></a>    function(identifier) {
<a name="line437"></a>
<a name="line438"></a>  return goog.ui.KeyboardShortcutHandler.EventType.SHORTCUT_PREFIX + identifier;
<a name="line439"></a>};
<a name="line440"></a>
<a name="line441"></a>
<a name="line442"></a>/**
<a name="line443"></a> * Builds stroke array from string representation of shortcut.
<a name="line444"></a> * @param {string} s String representation of shortcut.
<a name="line445"></a> * @return {Array.&lt;Object&gt;} The stroke array.
<a name="line446"></a> */
<a name="line447"></a>goog.ui.KeyboardShortcutHandler.parseStringShortcut = function(s) {
<a name="line448"></a>  // Normalize whitespace and force to lower case.
<a name="line449"></a>  s = s.replace(/[ +]*\+[ +]*/g, &#39;+&#39;).replace(/[ ]+/g, &#39; &#39;).toLowerCase();
<a name="line450"></a>
<a name="line451"></a>  // Build strokes array from string, space separates strokes, plus separates
<a name="line452"></a>  // individual keys.
<a name="line453"></a>  var groups = s.split(&#39; &#39;);
<a name="line454"></a>  var strokes = [];
<a name="line455"></a>  for (var group, i = 0; group = groups[i]; i++) {
<a name="line456"></a>    var keys = group.split(&#39;+&#39;);
<a name="line457"></a>    var keyCode, modifiers = goog.ui.KeyboardShortcutHandler.Modifiers.NONE;
<a name="line458"></a>    for (var key, j = 0; key = keys[j]; j++) {
<a name="line459"></a>      switch (key) {
<a name="line460"></a>        case &#39;shift&#39;:
<a name="line461"></a>          modifiers |= goog.ui.KeyboardShortcutHandler.Modifiers.SHIFT;
<a name="line462"></a>          continue;
<a name="line463"></a>        case &#39;ctrl&#39;:
<a name="line464"></a>          modifiers |= goog.ui.KeyboardShortcutHandler.Modifiers.CTRL;
<a name="line465"></a>          continue;
<a name="line466"></a>        case &#39;alt&#39;:
<a name="line467"></a>          modifiers |= goog.ui.KeyboardShortcutHandler.Modifiers.ALT;
<a name="line468"></a>          continue;
<a name="line469"></a>        case &#39;meta&#39;:
<a name="line470"></a>          modifiers |= goog.ui.KeyboardShortcutHandler.Modifiers.META;
<a name="line471"></a>          continue;
<a name="line472"></a>      }
<a name="line473"></a>      keyCode = goog.ui.KeyboardShortcutHandler.getKeyCode(key);
<a name="line474"></a>      break;
<a name="line475"></a>    }
<a name="line476"></a>    strokes.push({keyCode: keyCode, modifiers: modifiers});
<a name="line477"></a>  }
<a name="line478"></a>
<a name="line479"></a>  return strokes;
<a name="line480"></a>};
<a name="line481"></a>
<a name="line482"></a>
<a name="line483"></a>/**
<a name="line484"></a> * Adds a key event listener that triggers {@link #handleKeyDown_} when keys
<a name="line485"></a> * are pressed.
<a name="line486"></a> * @param {goog.events.EventTarget|EventTarget} keyTarget Event target that the
<a name="line487"></a> *     event listener should be attached to.
<a name="line488"></a> * @protected
<a name="line489"></a> */
<a name="line490"></a>goog.ui.KeyboardShortcutHandler.prototype.initializeKeyListener =
<a name="line491"></a>    function(keyTarget) {
<a name="line492"></a>  this.keyTarget_ = keyTarget;
<a name="line493"></a>
<a name="line494"></a>  goog.events.listen(this.keyTarget_, goog.events.EventType.KEYDOWN,
<a name="line495"></a>      this.handleKeyDown_, false, this);
<a name="line496"></a>  // Firefox 2 on mac does not fire a keydown event in conjunction with a meta
<a name="line497"></a>  // key if the action involves cutting/copying/pasting text.
<a name="line498"></a>  // In this case we capture the keyup (which is fired) and fake as
<a name="line499"></a>  // if the user had pressed the key to begin with.
<a name="line500"></a>  if (goog.userAgent.MAC &amp;&amp;
<a name="line501"></a>      goog.userAgent.GECKO &amp;&amp; goog.userAgent.isVersion(&#39;1.8&#39;)) {
<a name="line502"></a>    goog.events.listen(this.keyTarget_, goog.events.EventType.KEYUP,
<a name="line503"></a>        this.handleMacGeckoKeyUp_, false, this);
<a name="line504"></a>  }
<a name="line505"></a>};
<a name="line506"></a>
<a name="line507"></a>
<a name="line508"></a>/**
<a name="line509"></a> * Handler for when a keyup event is fired in Mac FF2 (Gecko 1.8).
<a name="line510"></a> * @param {goog.events.BrowserEvent} e The key event.
<a name="line511"></a> * @private
<a name="line512"></a> */
<a name="line513"></a>goog.ui.KeyboardShortcutHandler.prototype.handleMacGeckoKeyUp_ = function(e) {
<a name="line514"></a>  // Due to a bug in the way that Gecko v1.8 on Mac handles
<a name="line515"></a>  // cut/copy/paste key events using the meta key, it is necessary to
<a name="line516"></a>  // fake the keydown for the action keys (C,V,X) by capturing it on keyup.
<a name="line517"></a>  // This is because the keydown events themselves are not fired by the
<a name="line518"></a>  // browser in this case.
<a name="line519"></a>  // Because users will often release the meta key a slight moment
<a name="line520"></a>  // before they release the action key, we need to store whether the
<a name="line521"></a>  // meta key has been released recently to avoid &quot;flaky&quot; cutting/pasting
<a name="line522"></a>  // behavior.
<a name="line523"></a>  if (e.keyCode == goog.events.KeyCodes.MAC_FF_META) {
<a name="line524"></a>    this.metaKeyRecentlyReleased_ = true;
<a name="line525"></a>    goog.Timer.callOnce(function() {
<a name="line526"></a>      this.metaKeyRecentlyReleased_ = false;
<a name="line527"></a>    }, 400, this);
<a name="line528"></a>    return;
<a name="line529"></a>  }
<a name="line530"></a>
<a name="line531"></a>  var metaKey = e.metaKey || this.metaKeyRecentlyReleased_;
<a name="line532"></a>  if ((e.keyCode == goog.events.KeyCodes.C ||
<a name="line533"></a>      e.keyCode == goog.events.KeyCodes.X ||
<a name="line534"></a>      e.keyCode == goog.events.KeyCodes.V) &amp;&amp; metaKey) {
<a name="line535"></a>    e.metaKey = metaKey;
<a name="line536"></a>    this.handleKeyDown_(e);
<a name="line537"></a>  }
<a name="line538"></a>};
<a name="line539"></a>
<a name="line540"></a>
<a name="line541"></a>/**
<a name="line542"></a> * Removes the listener that was added by link {@link #initializeKeyListener}.
<a name="line543"></a> * @protected
<a name="line544"></a> */
<a name="line545"></a>goog.ui.KeyboardShortcutHandler.prototype.clearKeyListener = function() {
<a name="line546"></a>  goog.events.unlisten(this.keyTarget_, goog.events.EventType.KEYDOWN,
<a name="line547"></a>      this.handleKeyDown_, false, this);
<a name="line548"></a>  if (goog.userAgent.MAC &amp;&amp;
<a name="line549"></a>      goog.userAgent.GECKO &amp;&amp; goog.userAgent.isVersion(&#39;1.8&#39;)) {
<a name="line550"></a>    goog.events.unlisten(this.keyTarget_, goog.events.EventType.KEYUP,
<a name="line551"></a>        this.handleMacGeckoKeyUp_, false, this);
<a name="line552"></a>  }
<a name="line553"></a>  this.keyTarget_ = null;
<a name="line554"></a>};
<a name="line555"></a>
<a name="line556"></a>
<a name="line557"></a>/**
<a name="line558"></a> * Adds or removes a stroke node to/from the given parent node.
<a name="line559"></a> * @param {Object} parent Parent node to add/remove stroke to/from.
<a name="line560"></a> * @param {Array.&lt;Object&gt;} strokes Array of strokes for shortcut.
<a name="line561"></a> * @param {?string} identifier Identifier for the task performed by shortcut or
<a name="line562"></a> *     null to clear.
<a name="line563"></a> * @private
<a name="line564"></a> */
<a name="line565"></a>goog.ui.KeyboardShortcutHandler.setShortcut_ = function(parent,
<a name="line566"></a>                                                        strokes,
<a name="line567"></a>                                                        identifier) {
<a name="line568"></a>  var stroke = strokes.shift();
<a name="line569"></a>  var key = goog.ui.KeyboardShortcutHandler.makeKey_(stroke.keyCode,
<a name="line570"></a>                                                     stroke.modifiers);
<a name="line571"></a>  var node = parent[key];
<a name="line572"></a>  if (node &amp;&amp; identifier &amp;&amp; (strokes.length == 0 || goog.isString(node))) {
<a name="line573"></a>    throw Error(&#39;Keyboard shortcut conflicts with existing shortcut&#39;);
<a name="line574"></a>  }
<a name="line575"></a>
<a name="line576"></a>  if (strokes.length) {
<a name="line577"></a>    if (!node) {
<a name="line578"></a>      node = parent[key] = {};
<a name="line579"></a>    }
<a name="line580"></a>    goog.ui.KeyboardShortcutHandler.setShortcut_(node,
<a name="line581"></a>                                                 strokes,
<a name="line582"></a>                                                 identifier);
<a name="line583"></a>  }
<a name="line584"></a>  else {
<a name="line585"></a>    parent[key] = identifier;
<a name="line586"></a>  }
<a name="line587"></a>};
<a name="line588"></a>
<a name="line589"></a>
<a name="line590"></a>/**
<a name="line591"></a> * Returns shortcut for a specific set of strokes.
<a name="line592"></a> * @param {Array.&lt;number&gt;} strokes Strokes array.
<a name="line593"></a> * @param {number} opt_index Index in array to start with.
<a name="line594"></a> * @param {Object} opt_list List to search for shortcut in.
<a name="line595"></a> * @return {string|Object} The shortcut.
<a name="line596"></a> * @private
<a name="line597"></a> */
<a name="line598"></a>goog.ui.KeyboardShortcutHandler.prototype.getShortcut_ = function(
<a name="line599"></a>    strokes, opt_index, opt_list) {
<a name="line600"></a>
<a name="line601"></a>  var list = opt_list || this.shortcuts_;
<a name="line602"></a>  var index = opt_index || 0;
<a name="line603"></a>  var stroke = strokes[index];
<a name="line604"></a>  var node = list[stroke];
<a name="line605"></a>
<a name="line606"></a>  if (node &amp;&amp; !goog.isString(node) &amp;&amp; strokes.length - index &gt; 1) {
<a name="line607"></a>    return this.getShortcut_(strokes, index + 1, node);
<a name="line608"></a>  }
<a name="line609"></a>
<a name="line610"></a>  return node;
<a name="line611"></a>};
<a name="line612"></a>
<a name="line613"></a>
<a name="line614"></a>/**
<a name="line615"></a> * Checks if a particular keyboard shortcut is registered.
<a name="line616"></a> * @param {Array.&lt;Object&gt;} strokes Strokes array.
<a name="line617"></a> * @return {boolean} True iff the keyboard is registred.
<a name="line618"></a> * @private
<a name="line619"></a> */
<a name="line620"></a>goog.ui.KeyboardShortcutHandler.prototype.checkShortcut_ = function(strokes) {
<a name="line621"></a>  var node = this.shortcuts_;
<a name="line622"></a>  while (strokes.length &gt; 0 &amp;&amp; node) {
<a name="line623"></a>    var stroke = strokes.shift();
<a name="line624"></a>    var key = goog.ui.KeyboardShortcutHandler.makeKey_(stroke.keyCode,
<a name="line625"></a>                                                       stroke.modifiers);
<a name="line626"></a>    node = node[key];
<a name="line627"></a>    if (goog.isString(node)) {
<a name="line628"></a>      return true;
<a name="line629"></a>    }
<a name="line630"></a>  }
<a name="line631"></a>  return false;
<a name="line632"></a>};
<a name="line633"></a>
<a name="line634"></a>
<a name="line635"></a>/**
<a name="line636"></a> * Constructs key from key code and modifiers.
<a name="line637"></a> *
<a name="line638"></a> * The lower 8 bits are used for the key code, the following 3 for modifiers and
<a name="line639"></a> * the remaining bits are unused.
<a name="line640"></a> *
<a name="line641"></a> * @param {number} keyCode Numeric key code.
<a name="line642"></a> * @param {number} modifiers Required modifiers.
<a name="line643"></a> * @return {number} The key.
<a name="line644"></a> * @private
<a name="line645"></a> */
<a name="line646"></a>goog.ui.KeyboardShortcutHandler.makeKey_ = function(keyCode, modifiers) {
<a name="line647"></a>  // Make sure key code is just 8 bits and OR it with the modifiers left shifted
<a name="line648"></a>  // 8 bits.
<a name="line649"></a>  return (keyCode &amp; 255) | (modifiers &lt;&lt; 8);
<a name="line650"></a>};
<a name="line651"></a>
<a name="line652"></a>
<a name="line653"></a>/**
<a name="line654"></a> * Keypress handler.
<a name="line655"></a> * @param {goog.events.BrowserEvent} event Keypress event.
<a name="line656"></a> * @private
<a name="line657"></a> */
<a name="line658"></a>goog.ui.KeyboardShortcutHandler.prototype.handleKeyDown_ = function(event) {
<a name="line659"></a>  // Ignore Ctrl, Shift and ALT
<a name="line660"></a>  if (event.keyCode == goog.events.KeyCodes.SHIFT ||
<a name="line661"></a>      event.keyCode == goog.events.KeyCodes.CTRL ||
<a name="line662"></a>      event.keyCode == goog.events.KeyCodes.ALT) {
<a name="line663"></a>   return;
<a name="line664"></a>  }
<a name="line665"></a>
<a name="line666"></a>  var el = /** @type {Element} */ (event.target);
<a name="line667"></a>  if (el.tagName == &#39;TEXTAREA&#39; || el.tagName == &#39;INPUT&#39; ||
<a name="line668"></a>      el.tagName == &#39;BUTTON&#39; || el.tagName == &#39;SELECT&#39;) {
<a name="line669"></a>    // For events originating from a form element most keys are ignored,
<a name="line670"></a>    // unless a modifier key is pressed.
<a name="line671"></a>    if (!event.altKey &amp;&amp; !event.ctrlKey &amp;&amp; !event.metaKey &amp;&amp;
<a name="line672"></a>        !this.isValidShortcutKey_(event.keyCode, el)) {
<a name="line673"></a>      return;
<a name="line674"></a>    }
<a name="line675"></a>  } else if ((el.isContentEditable ||
<a name="line676"></a>       el.ownerDocument &amp;&amp; el.ownerDocument.designMode == &#39;on&#39;) &amp;&amp;
<a name="line677"></a>      !this.globalKeys_[event.keyCode] &amp;&amp; !this.allShortcutsAreGlobal_) {
<a name="line678"></a>    // For events originating from an element in editing mode we only let
<a name="line679"></a>    // global key codes through.  Don&#39;t check this for form elements, since
<a name="line680"></a>    // they always have isContentEditable in IE.
<a name="line681"></a>    return;
<a name="line682"></a>  }
<a name="line683"></a>
<a name="line684"></a>  var modifiers =
<a name="line685"></a>      (event.shiftKey ? goog.ui.KeyboardShortcutHandler.Modifiers.SHIFT : 0) |
<a name="line686"></a>      (event.ctrlKey ? goog.ui.KeyboardShortcutHandler.Modifiers.CTRL : 0) |
<a name="line687"></a>      (event.altKey ? goog.ui.KeyboardShortcutHandler.Modifiers.ALT : 0) |
<a name="line688"></a>      (event.metaKey ? goog.ui.KeyboardShortcutHandler.Modifiers.META : 0);
<a name="line689"></a>  var stroke = goog.ui.KeyboardShortcutHandler.makeKey_(event.keyCode,
<a name="line690"></a>                                                        modifiers);
<a name="line691"></a>
<a name="line692"></a>  // Check if any previous strokes where entered within the acceptable time
<a name="line693"></a>  // period.
<a name="line694"></a>  var node, shortcut;
<a name="line695"></a>  var now = goog.now();
<a name="line696"></a>  if (this.lastKeys_.strokes.length &amp;&amp; now - this.lastKeys_.time &lt;=
<a name="line697"></a>      goog.ui.KeyboardShortcutHandler.MAX_KEY_SEQUENCE_DELAY) {
<a name="line698"></a>    node = this.getShortcut_(this.lastKeys_.strokes);
<a name="line699"></a>  } else {
<a name="line700"></a>    this.lastKeys_.strokes.length = 0;
<a name="line701"></a>  }
<a name="line702"></a>
<a name="line703"></a>  // Check if this stroke triggers a shortcut, either on it&#39;s own or combined
<a name="line704"></a>  // with previous strokes.
<a name="line705"></a>  node = node ? node[stroke] : this.shortcuts_[stroke];
<a name="line706"></a>  if (!node) {
<a name="line707"></a>    node = this.shortcuts_[stroke];
<a name="line708"></a>    this.lastKeys_.strokes = [];
<a name="line709"></a>  }
<a name="line710"></a>  // Check if stroke triggers a node.
<a name="line711"></a>  if (node &amp;&amp; goog.isString(node)) {
<a name="line712"></a>    shortcut = node;
<a name="line713"></a>  }
<a name="line714"></a>
<a name="line715"></a>  // Entered stroke(s) are a part of a sequence, store stroke and record
<a name="line716"></a>  // time to allow the following stroke(s) to trigger the shortcut.
<a name="line717"></a>  else if (node) {
<a name="line718"></a>    this.lastKeys_.strokes.push(stroke);
<a name="line719"></a>    this.lastKeys_.time = now;
<a name="line720"></a>    // Prevent default action so find-as-you-type doesn&#39;t steal keybord focus.
<a name="line721"></a>    if (goog.userAgent.GECKO) {
<a name="line722"></a>      event.preventDefault();
<a name="line723"></a>    }
<a name="line724"></a>  }
<a name="line725"></a>
<a name="line726"></a>  // No strokes for sequence, clear stored strokes.
<a name="line727"></a>  else {
<a name="line728"></a>    this.lastKeys_.strokes.length = 0;
<a name="line729"></a>  }
<a name="line730"></a>
<a name="line731"></a>  // Dispatch keyboard shortcut event if a shortcut was triggered. In addition
<a name="line732"></a>  // to the generic keyboard shortcut event a more specifc fine grained one,
<a name="line733"></a>  // specific for the shortcut identifier, is fired.
<a name="line734"></a>  if (shortcut) {
<a name="line735"></a>    var types = goog.ui.KeyboardShortcutHandler.EventType;
<a name="line736"></a>
<a name="line737"></a>    // Dispatch SHORTCUT_TRIGGERED event
<a name="line738"></a>    var triggerEvent = new goog.ui.KeyboardShortcutEvent(
<a name="line739"></a>        types.SHORTCUT_TRIGGERED, shortcut, event.target);
<a name="line740"></a>    var retVal = this.dispatchEvent(triggerEvent);
<a name="line741"></a>
<a name="line742"></a>    // Dispatch SHORTCUT_PREFIX_&lt;identifier&gt; event
<a name="line743"></a>    var prefixEvent = new goog.ui.KeyboardShortcutEvent(
<a name="line744"></a>        types.SHORTCUT_PREFIX + shortcut, shortcut, event.target);
<a name="line745"></a>    retVal &amp;= this.dispatchEvent(prefixEvent);
<a name="line746"></a>
<a name="line747"></a>    // The default action is prevented if &#39;preventDefault&#39; was called on either
<a name="line748"></a>    // event, or if a listener returned false, or if the alwaysPreventDefault_
<a name="line749"></a>    // flag is enabled.
<a name="line750"></a>    if (this.alwaysPreventDefault_ || !retVal) {
<a name="line751"></a>      event.preventDefault();
<a name="line752"></a>    }
<a name="line753"></a>
<a name="line754"></a>    // Clear stored strokes
<a name="line755"></a>    this.lastKeys_.strokes.length = 0;
<a name="line756"></a>  }
<a name="line757"></a>};
<a name="line758"></a>
<a name="line759"></a>
<a name="line760"></a>/**
<a name="line761"></a> * Checks if a given key is allowed as a shortcut for the specified element.
<a name="line762"></a> * @param {number} keyCode Numeric key code.
<a name="line763"></a> * @param {Element} el Element the keyboard event originated from.
<a name="line764"></a> * @return {boolean} Whether a given key is allowed as a shortcut for the
<a name="line765"></a> *     specified element.
<a name="line766"></a> * @private
<a name="line767"></a> */
<a name="line768"></a>goog.ui.KeyboardShortcutHandler.prototype.isValidShortcutKey_ =
<a name="line769"></a>    function(keyCode, el) {
<a name="line770"></a>
<a name="line771"></a>  // Always allow keys registered as global to be used (typically Esc, the
<a name="line772"></a>  // F-keys and other keys that are not typically used to manipulate text).
<a name="line773"></a>  if (this.globalKeys_[keyCode] || this.allShortcutsAreGlobal_) {
<a name="line774"></a>    return true;
<a name="line775"></a>  }
<a name="line776"></a>
<a name="line777"></a>  // Allow ENTER to be used as shortcut for text inputs.
<a name="line778"></a>  if (el.tagName == &#39;INPUT&#39; &amp;&amp; (el.type == &#39;text&#39; || el.type == &#39;password&#39;)) {
<a name="line779"></a>    return keyCode == goog.events.KeyCodes.ENTER;
<a name="line780"></a>  }
<a name="line781"></a>
<a name="line782"></a>  // Checkboxes, radiobuttons and buttons. Allow all but SPACE as shortcut.
<a name="line783"></a>  if (el.tagName == &#39;INPUT&#39; || el.tagName == &#39;BUTTON&#39;) {
<a name="line784"></a>    return keyCode != goog.events.KeyCodes.SPACE;
<a name="line785"></a>  }
<a name="line786"></a>
<a name="line787"></a>  // Don&#39;t allow any additional shortcut keys for textareas or selects.
<a name="line788"></a>  if (el.tagName == &#39;TEXTAREA&#39; || el.tagName == &#39;SELECT&#39;) {
<a name="line789"></a>    return false;
<a name="line790"></a>  }
<a name="line791"></a>
<a name="line792"></a>  return true;
<a name="line793"></a>};
<a name="line794"></a>
<a name="line795"></a>
<a name="line796"></a>/**
<a name="line797"></a> * Object representing a keyboard shortcut event.
<a name="line798"></a> * @param {string} type Event type.
<a name="line799"></a> * @param {string} identifier Task identifier for the triggered shortcut.
<a name="line800"></a> * @param {Node|goog.events.EventTarget} target Target the original key press
<a name="line801"></a> *     event originated from.
<a name="line802"></a> * @extends {goog.events.Event}
<a name="line803"></a> * @constructor
<a name="line804"></a> */
<a name="line805"></a>goog.ui.KeyboardShortcutEvent = function(type, identifier, target) {
<a name="line806"></a>  goog.events.Event.call(this, type, target);
<a name="line807"></a>
<a name="line808"></a>  /**
<a name="line809"></a>   * Task identifier for the triggered shortcut
<a name="line810"></a>   * @type {string}
<a name="line811"></a>   */
<a name="line812"></a>  this.identifier = identifier;
<a name="line813"></a>};
<a name="line814"></a>goog.inherits(goog.ui.KeyboardShortcutEvent, goog.events.Event);
</pre>


</body>
</html>
